﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta name="renderer" content=”webkit|ie-comp|ie-stand”/>
    <meta name="viewport" content="width=device-width"/>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>

    <link href="/assets/plugins/pace/pace-theme-minimal.css" rel="stylesheet"/>
    <link href="/assets/plugins/font/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="/assets/plugins/bootstrap/bootstrap.min.css" rel="stylesheet"/>
    <link href="/assets/plugins/jquery/plugin/scrollbar/jquery.mCustomScrollbar.min.css" rel="stylesheet"/>
    <link href="/module/style/lr-common.css" rel="stylesheet"/>
    <link href="desktopTemp/index.css" rel="stylesheet"/>

    <script src="/assets/plugins/jquery/plugin/fullcalendar/js/jquery-1.7.2.min.js"></script>
    <script src="/assets/plugins/jquery/plugin/jquery-ui/jquery-ui.min.js"></script>

    <link href="/assets/plugins/jquery/plugin/fullcalendar/css/fullcalendar.css" rel="stylesheet"/>
    <script src="/assets/plugins/jquery/plugin/fullcalendar/js/fullcalendar.min.js"></script>

    <!--[if lt IE 9]>
    <script src="/assets/plugins/bootstrap/html5shiv.min.js"></script>
    <script src="/assets/plugins/bootstrap/respond.min.js"></script>
    <![endif]-->
    <style>
        .fc-content tbody {
            background-color: honeydew;
        }

        .fc-header {
            background-color: darkseagreen;
        }
    </style>

</head>
<body class="Chrome 64.0 lr-uitheme-top" style="padding: 0px;margin: 0px;">
<div class="lr-desktop-panel">
    <div class="col-xs-2">
        <div id="div_statics" class="portal-panel-content"
             style="overflow: hidden; padding-top: 10px; padding-left: 40px; padding-right: 40px;">
            <div class="row row-sm stats-container">
                <div class="col-xs-6 stat-col">
                    <div class="stat-icon" style="font-size: 50px;text-align: center;color: red;"><i
                            class="fa fa-bell-o"></i></div>
                    <div class="stat" style="text-align: center;">
                        <div id="need_count" class="value"> 0</div>
                        <div class="name"> 代办事项</div>
                    </div>
                </div>
                <div class="col-xs-6 stat-col">
                    <div class="stat-icon" style="font-size: 50px;text-align: center;color: green"><i
                            class="fa fa-flag-checkered"></i></div>
                    <div class="stat" style="text-align: center;">
                        <div id="already_count" class="value"> 0</div>
                        <div class="name"> 本周已办</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-xs-6">
        <div id="div_task3" class="portal-panel-content"
             style="overflow: hidden; padding-right: 30px; text-align: center;margin:0 auto;">

        </div>
    </div>
    <div class="col-xs-4">
        <div class="portal-panel-title">
            <i class="fa fa-envelope" style="color: green;"></i>
            <span id="span_email" class="active" style="cursor: pointer;">&nbsp;&nbsp;我的邮件&nbsp;/</span>
            <span id="span_files" class="notactive" style="cursor: pointer;">&nbsp;我的文件</span>（Top 5）
            <p id="more_files" style="float: right;font-size: 12px;cursor: pointer;">更多</p>
        </div>
        <div id="div_email" class="portal-panel-content"
             style="overflow: hidden; padding-top: 10px; padding-left: 30px; padding-right: 50px;height: 180px;">

        </div>
        <div id="div_files" class="portal-panel-content"
             style="overflow: hidden; padding-top: 10px; padding-left: 30px; padding-right: 50px;height: 180px;display: none">

        </div>
    </div>
    <div class="col-xs-8">
        <div id="pageayout" class="border" style="overflow: auto; padding: 0px;">
            <div id='calendar' class="calendar" style="margin: 10px;background: #fff; "></div>
        </div>
    </div>
    <div class="col-xs-4">、
        <div class="col-xs-12">
            <div class="portal-panel-title">
                <i class="fa fa-bullhorn" style="color: green;"></i><span class="active">&nbsp;&nbsp;公告</span>（Top 5）
                <p id="more_notices" style="float: right;font-size: 12px;cursor: pointer;">更多</p>
            </div>
            <div id="div_notices" class="portal-panel-content"
                 style="overflow: hidden; padding-top: 10px; padding-left: 30px; padding-right: 50px;height: 180px;">

            </div>
        </div>
        <div class="col-xs-12">
            <div class="portal-panel-title">
                <i class="fa fa-bookmark" style="color: green;"></i>
                <span id="span_task1" class="active" style="cursor: pointer;">&nbsp;&nbsp;待办任务&nbsp;/</span>
                <span id="span_task2" class="notactive" style="cursor: pointer;">&nbsp;已办任务</span>（Top 5）
                <p id="more_task" style="float: right;font-size: 12px;cursor: pointer;">更多</p>
            </div>
            <div id="div_task1" class="portal-panel-content"
                 style="overflow: hidden; padding-top: 10px; padding-left: 30px; padding-right: 50px;height: 180px;">

            </div>
            <div id="div_task2" class="portal-panel-content"
                 style="overflow: hidden; padding-top: 10px; padding-left: 30px; padding-right: 50px;height: 180px;display: none">

            </div>
        </div>
    </div>


</div>

<script src="/module/config.js"></script>
<script src="/assets/plugins/pace/pace.min.js"></script>
<script src="/assets/plugins/jquery/plugin/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>

<script src="desktopTemp/index.js"></script>
</body>
<script type="text/javascript">

    function loadData1() {
        //代办
        $.ajax({
            url: config.base_server() + 'wftasks?access_token=' + config.getToken().access_token,
            data: {
                page: 1,
                limit: 5,
                categoryId: 2
            },
            type: 'GET',
            //  dataType: "json",
            success: function (res) {
                $("#need_count").html(res.count);
                if (!!res.data) {
                    var $html = "";
                    for (var i = 0; i < res.data.length; i++) {
                        var flag = '审批';
                        if(res.data[i].taskType==3) {
                            flag = '查阅';
                        }
                        $html += ' <div class="lr-msg-line">';
                        $html += '    <a onclick="detail(\'' + res.data[i].id + '\',\'' + res.data[i].taskId + '\',\'' + res.data[i].taskType + '\',\''+ res.data[i].processName + '\')" href="#" style="text-decoration: none;">['+flag+']&nbsp;&nbsp;&nbsp;' + res.data[i].processName + '[' + res.data[i].code + ']</a>';
                        $html += '    <label>' + res.data[i].createTime + '</label>';
                        $html += '</div>';
                    }
                    $("#div_task1").append($html);
                }
            }
        });
    };

    function loadData2() {
        //已办
        $.ajax({
            url: config.base_server() + 'wftasks?access_token=' + config.getToken().access_token,
            data: {
                page: 1,
                limit: 5,
                categoryId: 3
            },
            type: 'GET',
            //  dataType: "json",
            success: function (res) {
                $("#already_count").html(res.count);
                if (!!res.data) {
                    var $html = "";
                    for (var i = 0; i < res.data.length; i++) {
                        var flag = '审批';
                        if(res.data[i].taskType==3) {
                            flag = '查阅';
                        }
                        $html += ' <div class="lr-msg-line">';
                        $html += '    <a onclick="detail(\'' + res.data[i].id + '\',\'' + res.data[i].taskId + '\',\'' + res.data[i].taskType + '\',\'' + res.data[i].processName + '\')" href="#" style="text-decoration: none;">['+flag+']&nbsp;&nbsp;&nbsp;' + res.data[i].processName + '[' + res.data[i].code + ']</a>';
                        $html += '    <label>' + res.data[i].createTime + '</label>';
                        $html += '</div>';
                    }
                    $("#div_task2").append($html);
                }
            }
        });
    };

    function loadData3() {
        $.ajax({
            url: config.base_server() + 'wfschemes?access_token=' + config.getToken().access_token,
            data: {
                page: 1,
                limit: 6
            },
            type: 'GET',
            //  dataType: "json",
            success: function (res) {
                var $html = "";
                if (!!res.data) {
                    for (var i = 0; i < res.data.length; i++) {
                        var index = i < 5 ? 1 : 2;
                        $html += ' <div onclick="detail2(\'' + res.data[i].id + '\',\'' + res.data[i].code + '\',\'' + res.data[i].name + '\')" class="appItemOut">';
                        $html += '     <div appitemindex="' + index + '" class="appItem">';
                        $html += '        <div class="appIcon icon' + (i + 1) + '"></div>';
                        $html += '        <div class="appText">' + res.data[i].name + '</div>';
                        $html += '    </div>';
                        $html += ' </div>';
                    }
                    $("#div_task3").append($html);
                }
            }
        });
    };

    function loadData4() {
        $.ajax({
            url: config.base_server() + 'fileinfos/top5?access_token=' + config.getToken().access_token,
            data: {},
            type: 'GET',
            //  dataType: "json",
            success: function (res) {
                var $html = "";
                if (!!res.data) {
                    var length = res.data.length > 4 ? 4 : res.data.length;
                    for (var i = 0; i < res.data.length; i++) {
                        $html += ' <div class="lr-msg-line">';
                        $html += '    <a target="_blank" href="' + res.data[i].url + '" style="text-decoration: none;"><img src="/assets/plugins/images/filetype/' + res.data[i].ext + '.png" style="width:30px;height:30px;padding:5px;margin-left:-5px;margin-right:5px;" />&nbsp;&nbsp;&nbsp;' + res.data[i].name + '</a>';
                        $html += '    <label>' + res.data[i].updateTime + '</label>';
                        $html += '</div>';
                    }
                    $("#div_files").append($html);
                }
            }
        });
    }

    function loadData5() {
        $.ajax({
            url: config.base_server() + 'notices/top5?access_token=' + config.getToken().access_token,
            data: {},
            type: 'GET',
            //  dataType: "json",
            success: function (res) {
                var $html = "";
                if (!!res.data) {
                    var $html = "";
                    for (var i = 0; i < res.data.length; i++) {
                        $html += ' <div class="lr-msg-line">';
                        $html += '    <a onclick="detail5(\'' + res.data[i].id + '\')" href="#" style="text-decoration: none;">[' + res.data[i].category + ']&nbsp;&nbsp;&nbsp;' + res.data[i].title + '</a>';
                        $html += '    <label>' + res.data[i].publicTime + '</label>';
                        $html += '</div>';
                    }
                    $("#div_notices").append($html);
                }
            }
        });
    }

    function loadData6() {
        $.ajax({
            url: config.base_server() + 'emails/list?type=1&access_token=' + config.getToken().access_token,
            data: {
                page: 1,
                limit: 5,
            },
            type: 'GET',
            //  dataType: "json",
            success: function (res) {
                if (!!res.data) {
                    var $html = "";
                    for (var i = 0; i < res.data.length; i++) {
                        var icon = '';
                        if (res.data[i].isRead != '1') {
                            icon = "<i class=\"fa fa-envelope\"></i>";
                        } else {
                            icon = "<i class=\"fa fa-envelope-open-o\"></i>";
                        }
                        $html += ' <div class="lr-msg-line">';
                        $html += '    <a onclick="detail6(\'' + res.data[i].id + '\')" href="#" style="text-decoration: none;">'+icon+'&nbsp;&nbsp;&nbsp;' + res.data[i].theme + '</a>';
                        $html += '    <label>' + res.data[i].senderTime + '</label>';
                        $html += '</div>';

                    }
                    $("#div_email").append($html);
                }
            }
        });
    };

    function detail(processId, taskId, taskType, processName) {
        if (top.learun.checkrow(processId)) {
            top.learun.frameTab.open({
                id: processId + taskId,
                css: 'fa magic',
                name: '查看流程进度【' + processName + '】',
                path: config.webportal_server + 'pages/workflow/wfmyTask/custmerWorkFlowForm.html?tabIframeId=' + processId + taskId + '&type=' + taskType + "&processId=" + processId + "&taskId=" + taskId + '&access_token=' + config.getToken().access_token
            });
        }
    }

    function detail2(id, shcemeCode, shcemeName) {
        top.learun.frameTab.open({
            id: id,
            css: 'fa magic',
            name: '发起流程【' + shcemeName + '】',
            path: config.webportal_server + 'pages/workflow/wfmyTask/custmerWorkFlowForm.html?shcemeCode=' + shcemeCode + '&tabIframeId=' + id + '&type=0&access_token=' + config.getToken().access_token,
        });
        return true;
    };

    function detail5(id) {
        top.learun.frameTab.open({
            id: 'View5',
            name: '查看公告',
            path: config.webportal_server + 'pages/system/notice/view.html?keyValue=' + id + '&access_token=' + config.getToken().access_token,
        });
        return true;
    };

    function detail6(id) {
        top.learun.frameTab.open({
            id: 'View6',
            name: '查看邮件',
            path: config.webportal_server + 'pages/system/email/detailForm.html?keyValue=' + id + '&access_token=' + config.getToken().access_token,
        });
        return true;
    };

    function moreRedirect() {
        $("#more_email").click(function () {
            top.learun.frameTab.open({
                id: top.learun.newGuid(),
                css: 'fa email',
                name: '邮件',
                path: config.webportal_server + 'pages/system/email/index.html?access_token=' + config.getToken().access_token
            });
        });
        $("#more_notices").click(function () {
            top.learun.frameTab.open({
                id: top.learun.newGuid(),
                css: 'fa file',
                name: '公告',
                path: config.webportal_server + 'pages/system/notice/index.html?access_token=' + config.getToken().access_token
            });
        });
        $("#more_task").click(function () {
            top.learun.frameTab.open({
                id: top.learun.newGuid(),
                css: 'fa task1',
                name: '我的代办',
                path: config.webportal_server + 'pages/workflow/wfmyTask/index.html?categoryId=2&access_token=' + config.getToken().access_token
            });
        })
    }

    //密码定时检测
    function validatePassword() {
        $.ajax({
            url: config.base_server() + 'users/validateModifyPassword?access_token=' + config.getToken().access_token,
            type: 'GET',
            success: function (res) {
                if (res.resp_code != 200) {
                    top.learun.layerConfirm('您有一段时间没有更新密码了，为了安全请尽快修改密码，是否立刻去修改?', function (res, index) {
                        if (res) {
                            top.layer.close(index);
                            top.learun.frameTab.open({
                                id: '1',
                                css: 'fa fa-user',
                                name: '修改密码',
                                path: '/pages/system/my/index.html?index=3&access_token=' + config.getToken().access_token
                            });
                        }
                    });
                }
            }
        });
    }


    $(document).ready(function () {
        loadData1();
        loadData2();
        loadData3();
        loadData4();
        loadData5();
        loadData6();
        toggleClick();
        moreRedirect();
        validatePassword();
        resize();
        $('.calendar').fullCalendar({
            header: {
                left: 'prev,next',
                center: 'title',
                right: 'agendaDay,agendaWeek,month'
            },
            monthNamesShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
            dayNamesShort: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
            buttonText: {
                prev: '上一页',
                next: '下一页',
                month: '月视图',
                week: '周视图',
                day: '日视图'
            },
            titleFormat: "yyyy年MM月",
            columnFormat: {
                month: 'ddd',
                week: 'MM月dd日 ddd',
                day: 'MM月dd日 ddd'
            },
            allDayText: '今天',
            axisFormat: "HH:00",
            height: $(window).height() - 295,
            dayClick: function (date, allDay, jsEvent, view) {
                var _date = $.fullCalendar.formatDate(date, 'yyyy-MM-dd');
                var _time = $.fullCalendar.formatDate(date, 'HHmm');
                if (top.learun.formatDate(_date, 'yyyyMMdd') >= (nowtime())) {
                    btn_add(_date, _time);
                }
            },
            eventClick: function(info) {
                btn_edit(info.id);
            },
            editable: true,
            eventLimit: true,
            eventAfterRender: function (event, element, view) {//数据绑定上去后添加相应信息在页面上
                var fstart = $.fullCalendar.formatDate(event.start, "HH:mm");
                var fend = $.fullCalendar.formatDate(event.end, "HH:mm");

                if (view.name == "month") {//按月份
                    var evtcontent = '<div class="fc-event-inner fc-event-skin">';
                    evtcontent += '<span class="fc-event-time">' + fstart + " - " + fend + '</span>';
                    evtcontent += '<span class="fc-event-title">: ' + event.title + '</span>';
                    evtcontent += '</div><div class="ui-resizable-handle ui-resizable-e">&nbsp;&nbsp;&nbsp;</div>';

                    element.html(evtcontent);
                } else {
                    var evtcontent = '<div class="fc-event-inner fc-event-skin">';
                    evtcontent += '<div class="fc-event-head fc-event-skin">';
                    evtcontent += '<div class="fc-event-time">' + fstart + " - " + fend + event.title + '</div>';
                    evtcontent += '</div>';
                    evtcontent += '<div class="fc-event-content"></div>';
                    evtcontent += '<div class="fc-event-bg"></div>';
                    evtcontent += '</div>';
                    element.html(evtcontent);
                }
            },
            events: (function () {
                var _data = [];
                $.ajax({
                    url: config.base_server() + 'calendartips/list?access_token=' + config.getToken().access_token,
                    type: "get",
                    dataType: "json",
                    async: false,
                    success: function (res) {
                        _data = res.data;
                    }
                });
                return _data;
            })()
        });

        // $('.lr-desktop-panel').css("height",$(window).height() - 300+"px;overflow-y:auto;");
    });

    function toggleClick() {
        $("#span_task1").click(function () {
            $("#span_task1").addClass("active").removeClass("notactive");
            $("#span_task2").addClass("notactive").removeClass("active");
            $("#div_task1").show();
            $("#div_task2").hide();

            $("#more_task").click(function () {
                top.learun.frameTab.open({
                    id: top.learun.newGuid(),
                    css: 'fa task1',
                    name: '我的代办',
                    path: config.webportal_server + 'pages/workflow/wfmyTask/index.html?categoryId=2&access_token=' + config.getToken().access_token
                });
            })
        });
        $("#span_task2").click(function () {
            $("#span_task2").addClass("active").removeClass("notactive");
            $("#span_task1").addClass("notactive").removeClass("active");
            $("#div_task2").show();
            $("#div_task1").hide();

            $("#more_task").click(function () {
                top.learun.frameTab.open({
                    id: top.learun.newGuid(),
                    css: 'fa task2',
                    name: '我的已办',
                    path: config.webportal_server + 'pages/workflow/wfmyTask/index.html?categoryId=3&access_token=' + config.getToken().access_token
                });
            })
        });

        $("#span_email").click(function () {
            $("#span_email").addClass("active").removeClass("notactive");
            $("#span_files").addClass("notactive").removeClass("active");
            $("#div_email").show();
            $("#div_files").hide();

            $("#more_email").click(function () {
                top.learun.frameTab.open({
                    id: top.learun.newGuid(),
                    css: 'fa email',
                    name: '邮件',
                    path: config.webportal_server + 'pages/system/email/index.html?access_token=' + config.getToken().access_token
                });
            });
        });
        $("#span_files").click(function () {
            $("#span_files").addClass("active").removeClass("notactive");
            $("#span_email").addClass("notactive").removeClass("active");
            $("#div_files").show();
            $("#div_email").hide();

            $("#more_email").click(function () {
                top.learun.frameTab.open({
                    id: top.learun.newGuid(),
                    css: 'fa file',
                    name: '文件',
                    path: config.webportal_server + 'pages/system/files/index.html?access_token=' + config.getToken().access_token
                });
            });
        });
    }

    function resize() {
        $('#pageayout').height($(window).height() - 20);
        $(window).resize(function (e) {
            window.setTimeout(function () {
                $('#pageayout').height($(window).height() - 20);
            }, 200);
            e.stopPropagation();
        });
    }

    //添加日程
    function btn_add(date, time) {
        top.learun.layerForm({
            id: 'form',
            title: '添加日程',
            url: config.webportal_server + 'pages/home/desktopTemp/form.html?startDate=' + escape(date) + '&startTime=' + time + '&access_token=' + config.getToken().access_token,
            width: 500,
            height: 350,
            callBack: function (id) {
                return top[id].acceptClick();
            }
        });
    };
    //编辑日程
    function btn_edit(id) {
        top.learun.layerForm({
            id: 'form',
            title: '编辑日程',
            url: config.webportal_server + 'pages/home/desktopTemp/form.html?keyValue='+ id +'&access_token=' + config.getToken().access_token,
            width: 500,
            height: 350,
            callBack: function (id) {
                return top[id].acceptClick();
            }
        });
    };
    function callback() {
        learun.reload();
    }

    function nowtime() {//将当前时间转换成yyyymmdd格式
        var mydate = new Date();
        var str = "" + mydate.getFullYear();
        var mm = mydate.getMonth() + 1
        if (mydate.getMonth() > 9) {
            str += mm;
        } else {
            str += "0" + mm;
        }
        if (mydate.getDate() > 9) {
            str += mydate.getDate();
        } else {
            str += "0" + mydate.getDate();
        }
        return str;
    }

</script>
</html>













